package cn.tedu.service.impl;

import cn.tedu.mapper.EmployeeMapper;
import cn.tedu.service.EmployeeService;
import cn.tedu.vo.WorkCount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;


    @Override
    public WorkCount countWork(String time,Integer id) {

        if (time.equalsIgnoreCase("today")){
            WorkCount workCount = employeeMapper.countWorkByToday(id);
            return employeeMapper.countWorkByToday(id);
        }else if(time.equalsIgnoreCase("week")){
            return employeeMapper.countWorkByWeek(id);
        }else if(time.equalsIgnoreCase("month")){
            return employeeMapper.countWorkByMonth(id);
        }else if(!StringUtils.isEmpty(time)){
            return employeeMapper.countWorkByTime(time,id);
        }
        throw new IllegalArgumentException("参数异常");
    }
}
